Primitive Subtyping ^ Implicit Polymorphism J = Object-orientation Extended Abstract
نویسنده
چکیده
1 Overview We present a new predicative and decidable type system called ML that adds primitive subtyp-ing to the ML type system 17]. Our goal is to devise a type discipline for a strongly typed, higher-order object-oriented language, building on well-understood concepts from type systems for functional languages, rather than on special calculi 1] or resorting to \ad-hoc" polymor-phism 19, 23], second-order systems 6, 21], or recursive types 4]. Instead, our system is based on the following ideas. We insist on a separation of interface and implementation. Interfaces de-ne types and method signatures, where subtyp-ing provides for a hierarchical, user-extensible modelling. Implementation modules may deene data types (in the form of tagged records), which form the leaves of the type hierarchy, as well as method implementations for speciic argument types. We do not model the inheritance of implementations (which we believe to be a purely syntactic notion) in the type system. We think of methods as sets of functions, similar in spirit to languages like CLOS 7] and Cecil 5], that dispatch on the run-time types of all their arguments. We enrich the original Hindley-Milner type system 12, 17] with polymorphic constrained types of the form 8#: : where # is a set of variables, is a constraint, and is a (quantiier-free) monotype. Before we deene these notions in detail in section 2, we would like to illustrate the use of our type system at the hand of the classical example of points in the two-dimensional plane, expressed in a ctitious language with full type annotations (see gure 1). We do not study type inference in this paper, although we will come back to this issue in the conclusion. The interface Point declares a zero-ary type constructor class Point as well as a type con-structor point. Type constructors are used to form complex type expressions; we identify a zero-ary type constructor such as point with the type point ]. Type constructor classes partition the universe of type constructors into dis-joint subuniverses. In particular, we consider two types incomparable if their outermost type constructors belong to diierent classes. In OO jargon, one would call the type point an \ab-stract class", because the interface does not de-ne an implementation for points. The interface Point speciies three methods dist, move, and leq that operate on objects of type point. Method dist has type point ! real, that is, it expects an argument of …
منابع مشابه
Subtyping and Parametricity
In this paper we study the interaction of subtyping and parametricity. We describe a logic for a programming language with parametric polymorphism and subtyping. The logic supports the formal definition and use of relational parametricity. We give two models for it, and compare it with other formal systems for the same language. In particular, we examine the “Penn interpretation” of subtyping a...
متن کاملSubtyping for Distributed Object Stores (extended Abstract)
I review the Liskov and Wing subtype deenition that takes into consideration the problem of subtyping in the presence of mutable objects. I then show how this notion of subtyping is relevant to the design of the TOM object repository whose main application today is a data type conversion service accesssible through the Web.
متن کاملRecursive Types Are not Conservative over F ≤ ( extended abstract )
F≤ is a type system used to study the integration of inclusion and parametric polymorphism. F≤ does not include a notion of recursive types, but extensions of F≤ with recursive types are widely used as a basis for foundational studies about the type systems of functional and object-oriented languages. In this paper we show that adding recursive types results in a non conservative extension of t...
متن کاملAn Extended Theory of Primitive Objects: FIrst Order System
We investigate a rst-order extension of the Theory of Primitive Objects of 5] that supports method extension in presence of object subsumption. Extension is the ability of modifying the behavior of an object by adding new methods (and inheriting the existing ones). Object subsumption allows to use objects with a bigger interface in a context expecting another object with a smaller interface. Th...
متن کاملOOHaskell
Haskell provides type-class-bounded and parametric polymorphism as opposed to subtype polymorphism of object-oriented languages such as Java and OCaml. It is a contentious question whether Haskell 98 without extensions, or with common extensions, or with new extensions can fully support conventional object-oriented programming with encapsulation, mutable state, inheritance, overriding, statical...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
دوره شماره
صفحات -
تاریخ انتشار 1996